<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表白墙</title>
</head>
<body>
<form action="message" method="post">
    <div class="container">
        <h1>表白墙</h1>
        <p>输入后点击提交，会将信息显示在表格中</p>
        <div class="row">
            <span>谁:</span>
            <input type="text" class="edit" name="from">
        </div>
        <div class="row">
            <span>对谁:</span>
            <input type="text" class="edit" name="to">
        </div>
        <div class="row">
            <span>说什么:</span>
            <input type="text" class="edit" name="message">
        </div>
        <div class="row">
            <input type="submit" id="submit" value="提交">
        </div>

        <div class="row" th:each="message: ${messages}">
            <span th:text="${message.from}"></span>
            对
            <span th:text="${message.to}"></span>
            说
            <span th:text="${message.message}"></span>
        </div>
    </div>
</form>

<!-- <script>
         let submitButton=document.querySelector('#submit');
         submitButton.onclick=function(){
             let edits=document.querySelectorAll('.edit');
             console.log(edits);
             let from=edits[0].value;
             let to=edits[1].value;
             let message=edits[2].value;
             console.log(from+","+to+","+message);
             if(from==null||to==null||message==null){
                 return;
             }
             let row=document.createElement('div');
             row.className='row';
             row.innerHTML=from+'对'+to+'说'+message;
             let container=document.querySelector('.container');
            container.appendChild(row);
            for(i=0;i<edits.length;i++){
                edits[i].value='';
            }
        //  }
    </script> -->
<style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .container{
            width: 400px;
            margin: 0 auto;
        }
        h1 {
            text-align: center;
            padding: 20px;
        }
        p{
            text-align: center;
            color:#666;
            padding: 10px 0;
            font-size: 14px;
        }
        .row{
            height: 50px;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        span{
            width: 90px;
            font-size: 20px;
        }
        input{
            width: 310px;
            height: 40px;
        }
        #submit{
            width: 400px;
            background-color: rgb(255,165,0);
            color: white;
            border: none;
            border-radius: 5px;
        }
        #submit:active{
            background-color: black;
        }
    </style>
</body>
</html>